<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>考试安排</title>
    <link href="../../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}">
    <link href="../../static/css/dashboard.css" rel="stylesheet" th:href="@{/static/css/dashboard.css}">
</head>
<body>
<div th:insert="admin/common::topbar"></div>
<div class="container-fluid">
    <div class="row">
        <!--侧边栏-->
        <div th:insert="~{admin/common::sidebar(active='examArrange.html')}">
        </div>
        <!--"-->
        <main class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4" role="main">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                <h3>考试安排</h3>
                <div class="btn-toolbar mb-2 mb-md-0">
                    <div class="btn-group mr-2">
                        <form id="form" method="post" th:action="@{/admin/toExamSubjectList}">
                            <!--onblur 失去焦点产生事件-->
                            <div class="input-group">
                                <select class="form-control" id="exam_id" name="exam_id">
                                    <option th:each="examlist:${examList}"
                                            th:selected="${examById.getExam_id()==examlist.getExam_id()}"
                                            th:text="${examlist.getExam_name()}" th:value="${examlist.getExam_id()}">
                                    </option>
                                </select>
                                <input class="input-group-addon btn btn-sm btn-primary" type="submit" value="搜索">
                            </div>
                        </form>
                    </div>
                    <div class="btn-group mr-2">
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-exam-info">考场详情</button>
                        <!-- <button id="btn-clear-stu-exam" class="btn btn-primary btn-sm btn-outline-secondary">清空考生座位</button>-->
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-arange-exam-place">自动安排考生
                        </button>
                    </div>
                    <div class="btn-group mr-2">
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-admin">管理员</button>
                        <button class="btn btn-sm btn-outline-secondary" id="btn-student">学生端</button>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead style="background-color: #00d0ff">
                    <tr>
                        <th style="color: #AB9C08">考试编号</th>
                        <th style="color: #067D14">考试名称</th>
                        <th style="color: #00f729">考试科目编号</th>
                        <th style="color: #AB9C08">考试科目</th>
                        <th>考试具体事项安排</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="examSubjectList" th:each="list:${examSubject}">
                        <th th:text="${list.getExam_id()}"></th>
                        <th th:text="${list.getExam_cname()}"></th>
                        <th th:text="${list.getExam_cid()}"></th>
                        <th th:text="${list.getExam_name()}"></th>
                        <th>
                            <button class="btn btn-sm  btn-outline-secondary " style="color: #899443"
                                    th:value="${list.getExam_cid()}">考试时间安排
                            </button>
                            <button class="btn btn-sm  btn-outline-secondary " style="color: #899443"
                                    th:value="${list.getExam_cid()}">考场监考人员安排
                            </button>
                            <button class="btn btn-primary btn-sm btn-outline-secondary" style="color: #899443">考试学生
                            </button>
                        </th>
                    </tr>
                    </tbody>
                </table>
            </div>
        </main>
    </div>
</div>
<script src="../../static/js/jquery-3.6.0.min.js" th:src="@{/static/js/jquery-3.6.0.min.js}"
        type="text/javascript"></script>
<script src="../../static/js/bootstrap.min.js" th:src="@{/static/js/bootstrap.min.js}" type="text/javascript"></script>
<script src="../../static/js/btn.js" th:src="@{/static/js/btn.js}"></script>
<script>
    let exam_id = [[${examById.getExam_id()}]];
    $(function () {
        $('.examSubjectList').each(function () {
            let btn_arrange_time = $(this).children().eq(4).children().eq(0);
            let btn_arrange_teacher = $(this).children().eq(4).children().eq(1);
            let btn_arrange_student = $(this).children().eq(4).children().eq(2);
            let exam_cid = $(this).children().eq(2).text();
            btn_arrange_teacher.click(function () {
                let exam_cid = btn_arrange_teacher.val();
                $(location).attr('href', '/admin/toArrangeExamTeacher/' + exam_id + '/' + exam_cid);
            })
            btn_arrange_time.click(function () {
                let exam_cid = btn_arrange_time.val();
                $(location).attr('href', '/admin/toArrangeExamTime/' + exam_id + '/' + exam_cid);
            })
            btn_arrange_student.click(function () {
                $(location).attr('href', '/admin/showStuExamInfo/' + exam_id + '/' + exam_cid + '/' + 1);
            })
        })
        $('#btn-exam-info').click(function () {
            $(location).attr('href', '/admin/showExamList/' + exam_id + '/' + 1);
        })
        $('#btn-arange-exam-place').click(function () {
            let confirm1 = confirm("确定自动安排考生考场位置!");
            if (confirm1 === true) {
                $(location).attr('href', '/admin/arrangeStuExamPlace/' + exam_id);
            }
        })
        /* $('#btn-clear-stu-exam').click(function (){
             let confirm2 = confirm("是否清空已经安排的考生位置");

         })*/
    })

</script>
</body>
</html>